package objects.ChooseLevelItem  
{
	import flash.events.Event;
	import flash.geom.Point;
	import objects.ChooseLevelItem.cicleItemChooseLevel;
	import objects.MyObject;
	import starling.display.Image;
	import starling.display.MovieClip;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.events.Touch;
	import starling.events.TouchEvent;
	import starling.events.TouchPhase;
	import starling.filters.BlurFilter;
	import com.greensock.*;
	import com.greensock.easing.*;
	
	/**
	 * ...
	 * @author ...Vượng
	 */
	public class ChooseLevelListItem extends MyObject
	{
		public var m_cicleItem:cicleItemChooseLevel;
		public var m_testChoose:Boolean;
		public var m_sprite:Sprite;
		public var m_testBuy:Boolean;
		public var resule:int;
		
		public function ChooseLevelListItem(_sprite:Sprite, _pos:Point)
		{
			m_sprite = _sprite;
			m_pos = _pos;
			m_cicleItem = new cicleItemChooseLevel(this, m_pos);
			this.addEventListener(starling.events.Event.ADDED_TO_STAGE, init);
			m_sprite.addEventListener(TouchEvent.TOUCH, onTouch);
			m_sprite.addChild(this);
			m_cicleItem.m_result = -1;
		}
		
		private function onTouch(e:TouchEvent):void
		{
			var touch:Touch = e.getTouch(stage);
			if (touch)
			{
				var _pointTouch:Point = new Point(touch.globalX, touch.globalY);
				if (touch.phase == TouchPhase.ENDED)
				{
					m_cicleItem.m_result = -1;
					for (var i:int = 0; i <m_cicleItem.m_baseItem.length; i++)
					{
						if (m_cicleItem.m_baseItem[i].bounds.containsPoint(_pointTouch) == true)
							{
								m_cicleItem.m_result = i;
								if (database.instance.m_testPlaySound == true)
									database.instance.m_Sound.playSound("Sound_Click");
							}
					}
				}
				else if(touch.phase == TouchPhase.HOVER)
				{					
					m_cicleItem.blurFilter(_pointTouch);
				}
			}
		}
		
		override public function update(dt:Number):void
		{

				

		}
		
		private function init(e:starling.events.Event):void
		{
			removeEventListener(starling.events.Event.ADDED_TO_STAGE, init);			
			this.setAnchorPoint();
			this.setPos(m_pos);
		}
		
		public function setAnchorPoint():void
		{
			
		}
		
		public function setPos(_pos:Point):void
		{
			
		}
		
		public function setScale(_scale:Number):void
		{
			
		}
		public function releaseFull(_listContain:Array,_index:int):void
		{	
			this.removeChildren();
			m_cicleItem.release();
			m_sprite.removeChild(this);
			_listContain.splice(_index, 1);
		}
	}

}